﻿using System;
using System.Web;

namespace Bingosoft.WebApp
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            // 让ASP.NET支持SqlServerCe3.5需要加入这一行
            AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            //bool processException = false;
            //Exception exception = Server.GetLastError().GetBaseException();
            //if (exception is HttpException)
            //{
            //    if (((HttpException)exception).GetHttpCode() == 500)
            //    {
            //        processException = true;
            //    }
            //}
            //else
            //{
            //    processException = true;
            //}

            //if (processException)
            //{
            //    string error = "出错页面是：" + Request.Url.ToString() + "\n";
            //    error += "异常信息：" + exception.Message + "\n";
            //    error += "Source:" + exception.Source + "\n";
            //    error += "StackTrace:" + exception.StackTrace + "\n";

            //    //记录日志
            //    Bingosoft.Common.Logging.LogManager.GetLogger(this.GetType()).Error(error);

            //    Server.ClearError();
            //    Application["error"] = error;
            //    Response.Redirect(("/".Equals(Request.ApplicationPath) ? "" : Request.ApplicationPath) + "/Shared/Pages/error/500.aspx");
            //}
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}